#include<iostream>
#include<vector>
#include<string>

using namespace std;

//正常句子
//如果两个单词之间有多个空格暂时不能处理
int main(){
	string str;
	vector<string> vec;
	while(1){
		getline(cin, str);
		if(str == "quit") return 0;
		vec.clear();

		int size = str.size(), left = size - 1, right = size - 1;
		for(int i = size -1; i >= 0; i--){
			if(str[i] == ' '){
				vec.emplace_back(str.substr(left,right - left + 1));
				left =  i - 1;
				right = left;
				continue;
			}
			left = i;
		}
		if(left != right)
			vec.emplace_back(str.substr(left,right - left + 1));
		//输出
		size = vec.size();
		for(int i = 0; i < size - 1; i ++)
			cout << vec[i] << " ";
		cout << vec[size - 1] << endl;
	}

	return 0;
}
